#include <iostream>
#include <string>
#include "log.hpp"
#include "TcpServer.hpp"
#include "Common.hpp"
#include "InetAddr.hpp"
#include <memory>

// 回调函数
std::string StringEcho(std::string &str)
{
    std::string ret = "client say:";
    return ret + str;
}

// server port
int main(int argc, char *argv[])
{
    // 判断命令行参数是否符合要求
    if (argc != 2)
    {
        std::cout << "Server ip" << std::endl;
        exit(ExitCode::USAGE_ERR);
    }

    uint16_t port = std::stoi(argv[1]);

    // 创建对应的Server对象
    std::shared_ptr<Server> server = std::make_shared<Server>(port, StringEcho);
    server->Init();
    server->Start();

    return 0;
}